import count from '@dfeidao/atom-nodejs/db/count';
import query from "@dfeidao/atom-nodejs/db/query";
import log from '@dfeidao/atom-nodejs/logger/log';
import { systemid } from '../../atom/config';
interface Message {
	company_name: string;
	corporate: string;
	page_no: number;
}

export default async function atom(msg: Message, action_id: string, session_id: string) {
	log(`Service begin`);
	// todo

	const { prepare, exec } = query(action_id, session_id, systemid);
	prepare('enterprise', ['company_no', 'company_name', 'corporate', 'high_company_name', 'nrollment_registration', 'company_unity_code', 'org_code', 'contacts_tel_two'], { company_name: msg.company_name, corporate: msg.corporate }, 10, msg.page_no, [], []);

	const [res] = await exec();

	const { prepare: p, exec: e } = count(action_id, session_id, systemid);
	p('enterprise', { company_name: msg.company_name, corporate: msg.corporate });

	const [t] = await e();
	log(`Service end`);
	return { res, t };
}
